package service.impl;

import dao.UserResourceDao;
import exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import service.UserResourceService;
import vo.UserResource;

@Service
public class UserResourceServiceImpl implements UserResourceService {

    @Autowired
    UserResourceDao dao;
    //查询是否购买过资源
    @Override
    public Boolean selectByUserIdAndResourceId(UserResource userResource) throws ServiceException {
        int result = dao.selectByUserIdAndResourceId(userResource);
        return result>0?true:false;
    }
    //更新最后一次观看资源的时间
    @Override
    public Boolean updateLastDateByUserIdAndResourceId(UserResource userResource) throws ServiceException {
        int result = dao.updateLastDateByUserIdAndResourceId(userResource);
        return result>0?true:false;
    }
    //将购买的资源加入到用户资源表
    @Override
    public Boolean insertMyResources(UserResource userResource) throws ServiceException {
        int result = dao.insertMyResources(userResource);
        return result>0?true:false;
    }


}
